/*====================================================================================
    EVS Codec 3GPP TS26.442 Sep 15, 2014. Version 12.0.0
  ====================================================================================*/

#include "options.h"     /* Compilation switches                   */
#include "stl.h"
#include "cnst_fx.h"       /* Common constants                       */
#include "rom_enc_fx.h"
#include "basop_util.h"
#include "vad_const.h"

/*----------------------------------------------------------------------------------*
 * VAD tables
 *----------------------------------------------------------------------------------*/
const Word16 hangover_hd_tbl_fx[3] = {1, 1, 3};
const Word16 hangover_sf_tbl_fx[6] = {1, 3, 4, 1, 1, 2};

const Word16 H_fir[]      = { 4260, 7536, 9175, 7536, 4260 };
const Word16 pit_max_12k8_fx[9] = { 11, 16, 21, 31, 40, 61, 77, 115, 115 };

const Word16 len_12k8_fx[4]     = { 40, 40, 62, 115 } ;
const Word16 len1_12k8_fx[4]    = { 40, 50, 80, 115 };
const Word16 sublen_12k8_fx[7]  = { 40, 40, 40, 62, 62, 115, 115 };
const Word16 sublen1_12k8_fx[7] = { 40, 40, 50, 50, 80,  80, 115 } ;

const Word16 sec_length_12k8_fx[4]  = {  7, 15, 30, 54 };
const Word16 sec_length1_12k8_fx[4] = { 10, 19, 37, 38 };
const Word16 SF_mult_fx[N_FEATURES] =
{
    20133,   /*Q22*/
    32767,   /*Q15*/
    20401,   /*Q15*/
    18013,   /*Q15*/
    16263,   /*Q15*/
    16545,   /*Q15*/
    16610,   /*Q15*/
    17197,   /*Q22*/
    18455,   /*Q23*/
    16515,   /*Q18*/
    17931,   /*Q18*/
    30382    /*Q18*/
};

const Word32 SF_add_fx[N_FEATURES] =
{
    -798595,   /*Q23*/
    0,   /*Q31*/
    -37312528,    /*Q29*/
    -67914170,    /*Q29*/
    -119722213,   /*Q29*/
    -220278135,   /*Q29*/
    -306929100,   /*Q29*/
    0,   /*Q30*/
    -6227703,   /*Q31*/
    537676218,   /*Q29*/
    488713591,   /*Q29*/
    -314713729    /*Q30*/
};

const Word16 SF_8k_mult_fx[N_FEATURES] =
{
    17197,   /*Q22*/
    28088,   /*Q15*/
    22082,   /*Q15*/
    20503,   /*Q15*/
    18006,   /*Q15*/
    18983,   /*Q15*/
    8199 ,   /*Q15*/
    17197,   /*Q22*/
    16777,   /*Q23*/
    16515,   /*Q18*/
    15676,   /*Q18*/
    16541     /*Q18*/
};

const Word32 SF_8k_add_fx[N_FEATURES] =
{
    0, /*Q23*/
    219043332, /*Q31*/
    -53687091, /*Q29*/
    -90086939, /*Q29*/
    -127775277, /*Q29*/
    -249430226, /*Q29*/
    0, /*Q29*/
    0, /*Q30*/
    0, /*Q31*/
    537676218, /*Q29*/
    481412147, /*Q29*/
    0  /*Q30*/
};

const Word16 w_fx[HANG_LEN][HANG_LEN] =
{
    /*Q15*/
    {32767,	     0,	     0,	     0,	     0,	     0,	     0,	     0,},
    {19661,	 13107,	     0,	     0,	     0,	     0,	     0,	     0,},
    {15401,	 10813,	  6554,	     0,	     0,	     0,	     0,	     0,},
    {13107,	  9830,	  6554,	  3277,	     0,	     0,	     0,	     0,},
    { 9830,	  8192,	  6554,	  4915,	  3277,	     0,	     0,	     0,},
    { 7635,	  6783,	  5898,	  5014,	  4162,	  3277,	     0,	     0,},
    { 7700,	  6717,	  5702,	  4686,	  3670,	  2654,	  1638,	     0,},
    { 6554,	  5865,	  5145,	  4456,	  3736,	  3047,	  2327,	  1638}
};
const Word16 m_speech_fx[N_MIXTURES*N_FEATURES] =
{
    /*Q15*/
    9436,	29987,	4795,	7076,	11050,	13645,	15206,	15194,	1936,	27952,	25172,	10301,
    10057,	30685,	8381,	9965,	10762,	8680,	11589,	15788,	1641,	26751,	27163,	10992,
    7927,	31230,	7191,	8505,	14304,	16336,	14972,	16077,	2052,	27271,	27694,	10859,
    13914,	17323,	10682,	16458,	17807,	18403,	19368,	12665,	2205,	29598,	29213,	11285,
    12468,	23848,	6880,	10301,	13824,	13066,	14647,	13189,	3451,	28442,	28766,	10410,
    11304,	21566,	7894,	11411,	14194,	15739,	16351,	13744,	6130,	28445,	28034,	11380
};
const Word32 invV_speech_fx[N_MIXTURES*N_FEATURES*N_FEATURES] =
{
    /*Q10*/
    -40443,	    -14756,	    -39560,	    -18113,	      8983,	    -11676,	       450,	    -10588,	    -49908,	       358,	     17222,	     32914,
    -14756,	   -200610,	    -27679,	    -28092,	    -16846,	     -6393,	      5954,	     13058,	    -67051,	    -47861,	     -8575,	     18740,
    -39560,	    -27679,	   -772035,	    118158,	    -48299,	     27758,	    -37782,	     74336,	   -305470,	    -23323,	    181510,	     91957,
    -18113,	    -28092,	    118158,	   -228070,	     41104,	    -46248,	     21977,	      8161,	    -27789,	     78357,	     26088,	     39736,
    8983,	    -16846,	    -48299,	     41104,	    -96670,	     41164,	    -18208,	      3995,	    -14774,	     23704,	     13802,	     17925,
    -11676,	     -6393,	     27758,	    -46248,	     41164,	    -95654,	     58562,	      3668,	       103,	      5952,	      9479,	     11083,
    450,	      5954,	    -37782,	     21977,	    -18208,	     58562,	    -91964,	     -5597,	    -47161,	    -15941,	     14870,	     11028,
    -10588,	     13058,	     74336,	      8161,	      3995,	      3668,	     -5597,	   -102767,	     25363,	    -21490,	    -48411,	     13509,
    -49908,	    -67051,	   -305470,	    -27789,	    -14774,	       103,	    -47161,	     25363,	  -1410848,	    -57997,	    238792,	   -117641,
    358,	    -47861,	    -23323,	     78357,	     23704,	      5952,	    -15941,	    -21490,	    -57997,	   -221932,	      -936,	     40579,
    17222,	     -8575,	    181510,	     26088,	     13802,	      9479,	     14870,	    -48411,	    238792,	      -936,	   -157118,	    -49202,
    32914,	     18740,	     91957,	     39736,	     17925,	     11083,	     11028,	     13509,	   -117641,	     40579,	    -49202,	   -321159,
    -54755,	    -48603,	      -918,	    -25735,	     31634,	    -27972,	     23305,	    -18449,	    -68162,	     -3670,	     -7982,	     35965,
    -48603,	   -449238,	    -11496,	    -14811,	     12790,	    -11453,	      2686,	     -3752,	    -86924,	    -30083,	    -54695,	     17457,
    -918,	    -11496,	   -258042,	    157642,	      4617,	     27546,	    -22677,	      7281,	   -221085,	    -48457,	     80126,	     16406,
    -25735,	    -14811,	    157642,	   -334462,	     64217,	      7724,	     24309,	     20322,	    -99420,	      2896,	     76924,	     35785,
    31634,	     12790,	      4617,	     64217,	   -296101,	    182629,	    -27282,	     11581,	    -10495,	     16901,	     50011,	     20823,
    -27972,	    -11453,	     27546,	      7724,	    182629,	   -274190,	     15505,	      4345,	     -7824,	     79496,	     -2218,	     12832,
    23305,	      2686,	    -22677,	     24309,	    -27282,	     15505,	    -73195,	      2055,	     -4690,	     31413,	     15447,	      8774,
    -18449,	     -3752,	      7281,	     20322,	     11581,	      4345,	      2055,	    -77913,	     57514,	     -8586,	   -106171,	      6233,
    -68162,	    -86924,	   -221085,	    -99420,	    -10495,	     -7824,	     -4690,	     57514,	  -1966183,	     -9074,	    512909,	    -17375,
    -3670,	    -30083,	    -48457,	      2896,	     16901,	     79496,	     31413,	     -8586,	     -9074,	   -185355,	    -15990,	      8445,
    -7982,	    -54695,	     80126,	     76924,	     50011,	     -2218,	     15447,	   -106171,	    512909,	    -15990,	   -444405,	    -71821,
    35965,	     17457,	     16406,	     35785,	     20823,	     12832,	      8774,	      6233,	    -17375,	      8445,	    -71821,	   -222292,
    -96397,	    -65745,	       316,	    -47258,	     43061,	    -42973,	     10442,	    -19582,	    -43973,	    -19682,	    -21732,	     48029,
    -65745,	   -838575,	     30816,	    -43250,	      6642,	     -4487,	     11239,	       338,	    -17329,	    -59741,	   -114530,	     -1706,
    316,	     30816,	   -351192,	    207585,	    -68100,	     60838,	    -83672,	     14796,	   -158998,	     13313,	    122647,	     38113,
    -47258,	    -43250,	    207585,	   -322741,	     76525,	    -99711,	     59838,	     20166,	    -63534,	      7136,	     76247,	     22923,
    43061,	      6642,	    -68100,	     76525,	    -96244,	     54110,	    -21689,	      2401,	    -36455,	    -19725,	     38782,	      6802,
    -42973,	     -4487,	     60838,	    -99711,	     54110,	   -284964,	    220150,	      -642,	    -44874,	    -21815,	     16040,	      3963,
    10442,	     11239,	    -83672,	     59838,	    -21689,	    220150,	   -239817,	      2018,	    -17214,	     -1904,	     16387,	      4095,
    -19582,	       338,	     14796,	     20166,	      2401,	      -642,	      2018,	    -58537,	     20742,	     -9245,	    -85094,	      8867,
    -43973,	    -17329,	   -158998,	    -63534,	    -36455,	    -44874,	    -17214,	     20742,	  -1009892,	     28181,	    407531,	    -10963,
    -19682,	    -59741,	     13313,	      7136,	    -19725,	    -21815,	     -1904,	     -9245,	     28181,	   -186118,	    -32487,	      5665,
    -21732,	   -114530,	    122647,	     76248,	     38782,	     16040,	     16387,	    -85094,	    407531,	    -32487,	   -511009,	    -66277,
    48029,	     -1706,	     38113,	     22923,	      6802,	      3963,	      4095,	      8867,	    -10963,	      5665,	    -66277,	   -251113,
    -21146,	      1393,	     -2365,	      3756,	     -4538,	     -1528,	      2298,	     -6668,	     -7599,	     -2720,	     -5226,	      3049,
    1393,	    -46612,	    -28502,	     11801,	     -5967,	      8395,	     -4182,	     13773,	     18586,	     -9799,	     -6696,	     -3522,
    -2365,	    -28502,	    -77446,	     55688,	    -10615,	     10476,	     -6282,	      5520,	    -19365,	      8818,	     -4576,	      2603,
    3756,	     11801,	     55688,	   -152293,	    104577,	     -8742,	     15278,	     -2773,	     16622,	    -12382,	     -2828,	      5452,
    -4538,	     -5967,	    -10615,	    104577,	   -245151,	    117173,	     -5020,	      3412,	     -2855,	    -19929,	      9729,	      1888,
    -1528,	      8395,	     10476,	     -8742,	    117173,	   -258943,	    136249,	     -2960,	     -8257,	    -20123,	     -6735,	     -6316,
    2298,	     -4182,	     -6282,	     15278,	     -5020,	    136249,	   -192889,	       889,	     -6047,	    -74906,	     15861,	      4026,
    -6668,	     13773,	      5520,	     -2773,	      3412,	     -2960,	       889,	   -298321,	      8558,	      5827,	    -66886,	     -3080,
    -7599,	     18586,	    -19365,	     16622,	     -2855,	     -8257,	     -6047,	      8558,	   -837495,	    -36576,	    477123,	    -58582,
    -2720,	     -9799,	      8818,	    -12382,	    -19929,	    -20123,	    -74906,	      5827,	    -36576,	   -279826,	     29479,	     36566,
    -5226,	     -6696,	     -4576,	     -2828,	      9729,	     -6735,	     15861,	    -66886,	    477123,	     29479,	  -1017755,	    -75828,
    3049,	     -3522,	      2603,	      5452,	      1888,	     -6316,	      4026,	     -3080,	    -58582,	     36566,	    -75828,	   -193453,
    -30403,	     -6761,	     -6085,	     -8388,	     12841,	    -17600,	      8289,	    -11817,	     -4054,	     -3000,	    -13322,	     14944,
    -6761,	    -28452,	    -12326,	     -8945,	     10515,	     -8369,	      -520,	      2242,	     -3287,	    -20124,	       179,	     12354,
    -6085,	    -12326,	   -180408,	     89468,	    -19908,	      3017,	    -41552,	      4204,	    -31158,	    -23783,	     87004,	     44784,
    -8388,	     -8945,	     89468,	   -146434,	     53166,	    -28645,	     29987,	     -2506,	    -12242,	     28411,	     11874,	       403,
    12841,	     10515,	    -19908,	     53166,	   -182342,	    131104,	     -3630,	      7016,	    -11031,	    -43497,	     35570,	     41136,
    -17600,	     -8369,	      3017,	    -28645,	    131104,	   -169537,	     52490,	     -4955,	      3848,	     41489,	     -7925,	    -19614,
    8289,	      -520,	    -41552,	     29987,	     -3630,	     52490,	   -111006,	      -916,	      3418,	      2295,	      3395,	      1491,
    -11817,	      2242,	      4204,	     -2506,	      7016,	     -4955,	      -916,	   -219477,	     -4965,	     -3871,	    -77054,	     -1199,
    -4054,	     -3287,	    -31158,	    -12242,	    -11031,	      3848,	      3418,	     -4965,	   -272588,	      2948,	    184352,	    -45153,
    -3000,	    -20124,	    -23783,	     28411,	    -43497,	     41489,	      2295,	     -3871,	      2948,	   -160538,	    -11875,	      4491,
    -13322,	       179,	     87004,	     11874,	     35570,	     -7925,	      3395,	    -77054,	    184352,	    -11875,	   -501251,	    -59166,
    14944,	     12354,	     44784,	       403,	     41136,	    -19614,	      1491,	     -1199,	    -45153,	      4491,	    -59166,	   -256669,
    -24496,	     -5820,	     -2150,	       131,	      5291,	    -10279,	      6605,	      -749,	     -2301,	     -4257,	      6742,	      4179,
    -5820,	    -30866,	     -8866,	    -12879,	     -1341,	      2042,	     -4488,	      6991,	      -847,	    -21654,	      3707,	     11359,
    -2150,	     -8866,	   -123923,	     90609,	    -28405,	     24864,	    -28222,	      3814,	      6439,	    -12821,	      2736,	     12974,
    131,	    -12879,	     90609,	   -147490,	     86712,	    -38319,	     26159,	      1048,	     -7654,	     17099,	      8973,	      1271,
    5291,	     -1341,	    -28405,	     86712,	   -147877,	     74296,	    -14561,	      2055,	     18062,	      1238,	     -4181,	     14726,
    -10279,	      2042,	     24864,	    -38319,	     74296,	   -168459,	    117891,	      -874,	    -17255,	       675,	     13174,	    -13101,
    6605,	     -4488,	    -28222,	     26159,	    -14561,	    117891,	   -147764,	    -13296,	      2771,	     -4243,	     -4809,	      1608,
    -749,	      6991,	      3814,	      1048,	      2055,	      -874,	    -13296,	    -77582,	    -32335,	     -4868,	      9778,	     -6784,
    -2301,	      -847,	      6439,	     -7654,	     18062,	    -17255,	      2771,	    -32335,	    -69840,	     11490,	     21385,	    -23633,
    -4257,	    -21654,	    -12821,	     17099,	      1238,	       675,	     -4243,	     -4868,	     11490,	   -151841,	     -2520,	     12898,
    6742,	      3707,	      2736,	      8973,	     -4181,	     13174,	     -4809,	      9778,	     21385,	     -2520,	    -60529,	     -3814,
    4179,	     11359,	     12974,	      1271,	     14726,	    -13101,	      1608,	     -6784,	    -23633,	     12898,	     -3814,	    -63927
};
const Word32 lvm_speech_fx[N_MIXTURES] =
{
    /*Q10*/
    32765,	     33549,	     33755,	     32747,	     31627,	     26814
};
const Word16 m_music_fx[N_MIXTURES*N_FEATURES] =
{
    /*Q15*/
    14804,	 25446,	  8882,	 11624,	 12963,	 13563,	 14794,	 20567,	  1033,	 27373,	 23772,	 11713,
    15975,	 20612,	  7737,	 12728,	 14424,	 15237,	 16190,	 15239,	  2277,	 30096,	 28120,	 11522,
    17631,	 19827,	  9280,	 14111,	 15555,	 16289,	 17009,	 17271,	  1132,	 31186,	 27733,	 12469,
    15863,	 24390,	  7804,	 11176,	 11734,	 11986,	 12857,	 23015,	   713,	 28823,	 23782,	 13779,
    10022,	 22691,	 12397,	 15249,	 15957,	 16382,	 17058,	 15509,	  4107,	 23807,	 22701,	 12269,
    16842,	 22819,	  8062,	 11248,	 12283,	 12978,	 13722,	 21178,	   867,	 30480,	 25501,	 12111
};
const Word32 invV_music_fx[N_MIXTURES*N_FEATURES*N_FEATURES] =
{
    /*Q10*/
    -7878,	      -673,	     -2037,	      -885,	      -236,	      -667,	       749,	     -1726,	    -20424,	      -859,	      2463,	      4011,
    -673,	    -31356,	     -1591,	     -3048,	     -1872,	      1277,	     -3806,	      8836,	      5555,	     -2031,	    -11076,	     -7329,
    -2037,	     -1591,	    -65556,	     42935,	    -11408,	     12166,	       751,	      8792,	     24077,	    -15804,	     -2546,	     -2517,
    -885,	     -3048,	     42935,	    -88483,	     42957,	    -13081,	      4776,	     14411,	     23734,	     -5735,	     15306,	     15210,
    -236,	     -1872,	    -11408,	     42957,	    -90738,	     37950,	     -1795,	      4021,	    -35266,	     12445,	     13655,	     17403,
    -667,	      1277,	     12166,	    -13081,	     37950,	    -86289,	     37943,	      3429,	     -5655,	      5664,	      8658,	       -11,
    749,	     -3806,	       751,	      4776,	     -1795,	     37943,	    -77863,	     -8515,	    -74265,	     22313,	      3842,	       645,
    -1726,	      8836,	      8792,	     14411,	      4021,	      3429,	     -8515,	    -59311,	   -121235,	      1622,	     -8500,	      4967,
    -20424,	      5555,	     24077,	     23734,	    -35266,	     -5655,	    -74265,	   -121235,	  -5534279,	    175865,	    247781,	   -296138,
    -859,	     -2031,	    -15804,	     -5735,	     12445,	      5664,	     22313,	      1622,	    175865,	   -104343,	     -1168,	     32220,
    2463,	    -11076,	     -2546,	     15306,	     13655,	      8658,	      3842,	     -8500,	    247781,	     -1168,	    -79522,	    -45571,
    4011,	     -7329,	     -2517,	     15210,	     17403,	       -11,	       645,	      4967,	   -296138,	     32220,	    -45571,	   -249005,
    -10115,	       613,	     -4406,	      -403,	       731,	       898,	       350,	     -1995,	     -8975,	      -169,	     -1296,	      1233,
    613,	    -30663,	    -12425,	     -1115,	     -1862,	      2906,	     -2485,	     12887,	     -8842,	    -12067,	      4833,	      3070,
    -4406,	    -12425,	    -86550,	     49625,	    -11519,	     15386,	    -20054,	     20873,	    -13684,	     28341,	     23152,	      -807,
    -403,	     -1115,	     49625,	   -131210,	     81002,	      1045,	      3085,	      8149,	    -11887,	     -3094,	     43855,	     14533,
    731,	     -1862,	    -11519,	     81002,	   -226160,	    115669,	      9052,	     -6427,	    -19605,	    -20406,	      7481,	      6064,
    898,	      2906,	     15386,	      1045,	    115669,	   -281745,	    150559,	     -5530,	       271,	     -5717,	      1673,	      7674,
    350,	     -2485,	    -20054,	      3085,	      9052,	    150559,	   -200735,	    -21872,	     -9366,	     10471,	     -2190,	      3083,
    -1995,	     12887,	     20873,	      8149,	     -6427,	     -5530,	    -21872,	   -111299,	    -29613,	    -27611,	    -54741,	     -9432,
    -8975,	     -8842,	    -13684,	    -11887,	    -19605,	       271,	     -9366,	    -29613,	   -616730,	     74872,	    189453,	    -79618,
    -169,	    -12067,	     28341,	     -3094,	    -20406,	     -5717,	     10471,	    -27611,	     74872,	   -359342,	    -12919,	     29609,
    -1296,	      4833,	     23152,	     43855,	      7481,	      1673,	     -2190,	    -54741,	    189453,	    -12919,	   -407670,	    -16961,
    1233,	      3070,	      -807,	     14533,	      6064,	      7674,	      3083,	     -9432,	    -79618,	     29609,	    -16961,	   -180700,
    -12411,	      5539,	     -1902,	        92,	      2813,	       339,	      -114,	     -1078,	    -24097,	     -2938,	     -1812,	       399,
    5539,	    -36224,	     -7229,	      -766,	     -2442,	      2066,	     -2896,	      8507,	     16429,	    -11423,	    -12067,	      -191,
    -1902,	     -7230,	   -115426,	     44336,	     11635,	     13946,	     -3573,	     22728,	    -73099,	    119214,	     70165,	      4686,
    92,	      -766,	     44336,	   -187908,	     81624,	     24838,	     12765,	      1471,	    -43322,	    -24066,	     44669,	      3543,
    2813,	     -2442,	     11635,	     81624,	   -295220,	    104190,	     52986,	     -3246,	   -146322,	    -78690,	     34365,	     -2814,
    339,	      2066,	     13946,	     24838,	    104190,	   -347659,	    169287,	     -4458,	   -127093,	    -94499,	     42989,	      5700,
    -114,	     -2896,	     -3573,	     12765,	     52986,	    169287,	   -310084,	    -18605,	    -27182,	    -19113,	     -2714,	        11,
    -1078,	      8507,	     22728,	      1471,	     -3246,	     -4458,	    -18605,	    -69283,	     40578,	    -47905,	   -135760,	     -6645,
    -24097,	     16429,	    -73099,	    -43322,	   -146322,	   -127093,	    -27182,	     40578,	  -8241631,	    -71531,	   1853193,	   -175523,
    -2938,	    -11423,	    119214,	    -24066,	    -78690,	    -94499,	    -19113,	    -47905,	    -71531,	  -1361618,	    -36609,	     26675,
    -1812,	    -12067,	     70165,	     44669,	     34365,	     42989,	     -2714,	   -135760,	   1853193,	    -36609,	  -1337597,	    -83909,
    399,	      -191,	      4686,	      3543,	     -2814,	      5700,	        11,	     -6645,	   -175523,	     26675,	    -83909,	   -223653,
    -8809,	      3326,	     -1275,	     -1509,	      1423,	      1222,	      -767,	     -3923,	    -65513,	     -5992,	      9965,	      3853,
    3326,	    -31906,	     -1905,	      4114,	     -4704,	      1138,	      -584,	     10709,	    104184,	      6118,	    -30358,	     -5240,
    -1275,	     -1905,	   -184413,	     67973,	    -17415,	     32246,	     -7121,	     16051,	     -2994,	    -52989,	     23547,	     27770,
    -1509,	      4114,	     67973,	   -160389,	     86351,	     -8947,	     13772,	      8224,	      3480,	      2626,	     24337,	      1870,
    1423,	     -4704,	    -17415,	     86351,	   -198772,	     68001,	      7361,	     14025,	     11152,	     23137,	     12598,	      9972,
    1222,	      1138,	     32246,	     -8947,	     68001,	   -166130,	     57911,	     17629,	    118765,	     39472,	      1806,	      7267,
    -767,	      -584,	     -7121,	     13772,	      7361,	     57911,	   -123203,	      2059,	     47920,	     59494,	     10484,	     -5066,
    -3923,	     10709,	     16051,	      8224,	     14025,	     17629,	      2059,	    -90332,	   -367027,	    -30259,	    -20438,	     -3054,
    -65513,	    104184,	     -2994,	      3480,	     11152,	    118765,	     47920,	   -367027,	 -16854832,	   -181537,	    903929,	    -95027,
    -5992,	      6118,	    -52989,	      2626,	     23137,	     39472,	     59494,	    -30259,	   -181537,	   -320917,	    -11497,	     56536,
    9965,	    -30358,	     23547,	     24337,	     12598,	      1806,	     10484,	    -20438,	    903929,	    -11497,	   -197437,	    -16106,
    3853,	     -5240,	     27770,	      1870,	      9972,	      7267,	     -5066,	     -3054,	    -95027,	     56536,	    -16106,	   -107942,
    -14599,	     -2426,	     -4488,	      2252,	        20,	      -696,	     -2636,	      5531,	      1097,	       109,	      1359,	      2742,
    -2426,	    -22977,	      1326,	     -4413,	     -6555,	       199,	     -2249,	     16239,	      6914,	     -6267,	      1335,	      -319,
    -4488,	      1326,	    -38846,	     40605,	    -16372,	      -138,	      6341,	      2358,	     -5859,	      1498,	     -1344,	     -3917,
    2252,	     -4413,	     40605,	    -94592,	     69176,	     -3799,	    -16812,	     -5416,	    -11189,	     -3107,	      2060,	     -3508,
    20,	     -6555,	    -16372,	     69176,	   -121278,	     55283,	        86,	      3716,	     11782,	     -9657,	      3416,	       549,
    -696,	       199,	      -138,	     -3799,	     55283,	   -105539,	     62225,	      5299,	      3619,	      1933,	     -2511,	       609,
    -2636,	     -2249,	      6341,	    -16812,	        86,	     62225,	    -79693,	     -7236,	     -9729,	     -2907,	      2795,	        57,
    5531,	     16239,	      2358,	     -5416,	      3716,	      5299,	     -7236,	    -52597,	    -40766,	     -5195,	      2995,	     11158,
    1097,	      6914,	     -5859,	    -11189,	     11782,	      3619,	     -9729,	    -40766,	    -95884,	     18462,	      2795,	    -18509,
    109,	     -6267,	      1498,	     -3107,	     -9657,	      1933,	     -2907,	     -5195,	     18462,	    -29138,	      3027,	     17268,
    1359,	      1335,	     -1344,	      2060,	      3416,	     -2511,	      2795,	      2995,	      2795,	      3027,	    -10878,	     -6828,
    2742,	      -319,	     -3917,	     -3508,	       549,	       609,	        57,	     11158,	    -18509,	     17268,	     -6828,	    -48324,
    -9462,	      2969,	     -1087,	     -1924,	      1418,	      -350,	       396,	     -3124,	    -35326,	       682,	      3248,	      5848,
    2969,	    -29148,	     -2662,	      2400,	     -3059,	      2772,	       847,	      8375,	     60040,	     -6778,	    -23223,	     -7694,
    -1087,	     -2662,	   -172602,	     83798,	      2597,	     33012,	      3851,	     12397,	     81998,	    -81017,	     15831,	     35467,
    -1924,	      2400,	     83798,	   -204141,	     66003,	      2928,	     18028,	     14706,	      8557,	     16030,	     44283,	     36177,
    1418,	     -3059,	      2597,	     66003,	   -202589,	     47215,	     19493,	     10544,	     -4664,	     46480,	     10895,	     18165,
    -350,	      2772,	     33012,	      2928,	     47215,	   -198011,	     76335,	     14223,	    123301,	     70945,	      1870,	      8265,
    396,	       847,	      3851,	     18028,	     19493,	     76335,	   -177594,	     -5345,	     78880,	    114804,	      -171,	      3539,
    -3124,	      8375,	     12397,	     14706,	     10544,	     14223,	     -5345,	    -67596,	   -251454,	    -55035,	    -21890,	      7263,
    -35326,	     60040,	     81998,	      8557,	     -4664,	    123301,	     78880,	   -251454,	 -12784658,	   -217014,	    810245,	   -725111,
    682,	     -6778,	    -81017,	     16030,	     46480,	     70945,	    114804,	    -55035,	   -217014,	   -793758,	     -8106,	     74886,
    3248,	    -23223,	     15831,	     44283,	     10895,	      1870,	      -171,	    -21890,	    810245,	     -8106,	   -319630,	    -77833,
    5848,	     -7694,	     35467,	     36177,	     18165,	      8265,	      3539,	      7263,	   -725111,	     74886,	    -77832,	   -481222
};
const Word32 lvm_music_fx[N_MIXTURES] =
{
    /*Q10*/
    28603,	     31076,	     35357,	     31989,	     20938,	     34395
};
const Word16 m_noise_fx[N_MIXTURES*N_FEATURES] =
{
    /*Q15*/
    14825,	 18681,	  7930,	 11230,	 13228,	 13602,	 14556,	 14377,	  1133,	 29263,	 26842,	 13270,
    14312,	 14992,	  9378,	 12891,	 14075,	 14581,	 15548,	 12386,	  1050,	 32143,	 28322,	 12379,
    18179,	 16617,	  8015,	 13153,	 13932,	 14462,	 15329,	 11848,	  1033,	 31841,	 28406,	 12222,
    15822,	 17883,	  3231,	  8086,	  9983,	  9933,	 11537,	 11904,	  1018,	 29549,	 27473,	 11111,
    13821,	 16109,	  8734,	 12035,	 13351,	 13603,	 15024,	 12957,	  1163,	 31179,	 28243,	 11865,
    13845,	 15577,	 10545,	 14292,	 15353,	 15784,	 16567,	 12750,	  1589,	 31695,	 28796,	 13420
};
const Word32 invV_noise_fx[N_MIXTURES*N_FEATURES*N_FEATURES] =
{
    /*Q10*/
    -11129,	      -775,	      -807,	      4750,	     -4310,	     -1632,	      1694,	       530,	    -25134,	     -2399,	      1632,	      1938,
    -775,	    -43700,	     -5296,	    -23144,	     -4086,	     -2008,	      9445,	     12956,	     17119,	     10623,	    -18169,	    -14373,
    -807,	     -5296,	   -117924,	     78859,	    -23526,	     22681,	     -7637,	     52382,	     20661,	     -1131,	     18004,	    -18669,
    4750,	    -23144,	     78859,	   -165973,	     70704,	      -954,	     10160,	      6713,	     50481,	     19307,	    -10190,	     16924,
    -4310,	     -4086,	    -23526,	     70704,	   -186160,	    114906,	    -28994,	      9999,	     17677,	    -18372,	    -20805,	    -12577,
    -1632,	     -2008,	     22681,	      -954,	    114906,	   -235840,	    123708,	     -3753,	     21616,	      9200,	     15641,	    -10616,
    1694,	      9445,	     -7637,	     10160,	    -28994,	    123708,	   -156081,	     -1564,	     -7627,	      5159,	     14184,	    -12573,
    530,	     12956,	     52382,	      6713,	      9999,	     -3753,	     -1564,	   -116541,	   -130257,	     -2892,	    -51260,	     -1433,
    -25134,	     17119,	     20661,	     50481,	     17677,	     21616,	     -7627,	   -130257,	  -6857531,	    -23164,	    425725,	   -172307,
    -2399,	     10623,	     -1131,	     19307,	    -18372,	      9200,	      5159,	     -2892,	    -23164,	   -157605,	      9307,	     20639,
    1632,	    -18169,	     18004,	    -10190,	    -20805,	     15641,	     14184,	    -51260,	    425725,	      9307,	   -184817,	     -2232,
    1938,	    -14373,	    -18669,	     16924,	    -12577,	    -10616,	    -12573,	     -1433,	   -172307,	     20639,	     -2232,	    -94498,
    -23585,	     -1283,	      2220,	      5814,	     -1063,	     -5524,	      5040,	      -408,	     -7744,	     65700,	     -4948,	      1221,
    -1283,	   -102238,	     18435,	    -18156,	     -6216,	     17104,	     -1870,	     25097,	     97427,	     32242,	    -77595,	     -4567,
    2220,	     18435,	   -305438,	    139861,	     24123,	     32851,	    -45614,	     45538,	    124040,	    301172,	    -22649,	      3625,
    5814,	    -18156,	    139861,	   -565373,	    242575,	     46852,	     50718,	    -18774,	   -159188,	    141029,	     89911,	      9768,
    -1063,	     -6216,	     24123,	    242575,	   -798475,	    256535,	    104095,	      9375,	    -84525,	   -408528,	     98204,	      4495,
    -5524,	     17104,	     32851,	     46852,	    256535,	   -845586,	    312678,	     -6990,	     50242,	   -543393,	    -42629,	        99,
    5040,	     -1870,	    -45614,	     50718,	    104095,	    312678,	   -732093,	     14409,	     83177,	   -140864,	     -2169,	     -2321,
    -408,	     25097,	     45538,	    -18774,	      9375,	     -6990,	     14409,	   -314037,	    273543,	    -30059,	   -253352,	     -3462,
    -7744,	     97427,	    124040,	   -159188,	    -84525,	     50242,	     83177,	    273543,	 -19301626,	   -952154,	   3668367,	    -93870,
    65700,	     32242,	    301172,	    141029,	   -408528,	   -543393,	   -140864,	    -30059,	   -952154,	 -16033274,	   -164405,	    -24189,
    -4948,	    -77595,	    -22649,	     89911,	     98204,	    -42629,	     -2169,	   -253352,	   3668367,	   -164405,	  -2501887,	   -105127,
    1221,	     -4567,	      3625,	      9768,	      4495,	        99,	     -2321,	     -3462,	    -93870,	    -24189,	   -105127,	   -252171,
    -11556,	      5444,	      1053,	      1823,	     -1754,	     -6509,	      3535,	      -483,	      5751,	     22898,	     -4369,	      2503,
    5444,	    -61418,	    -46603,	       523,	     -4221,	      5377,	    -14703,	      2336,	      4414,	      4601,	     17795,	      5358,
    1053,	    -46603,	   -197022,	     61944,	     30015,	     11139,	    -14163,	      4583,	     14704,	    174734,	    105587,	      3797,
    1823,	       523,	     61944,	   -579713,	    310766,	    -24876,	     -8601,	     -1522,	    -38055,	   -308764,	     10254,	     11526,
    -1754,	     -4221,	     30015,	    310766,	   -873205,	    294102,	      7806,	      2338,	    -28081,	   -507955,	     -5526,	     -1671,
    -6509,	      5377,	     11139,	    -24876,	    294102,	   -740664,	    309186,	    -19342,	    -50840,	   -143800,	     27527,	      4324,
    3535,	    -14703,	    -14163,	     -8601,	      7806,	    309186,	   -508227,	     24986,	    208442,	   -230010,	    -48336,	     -9651,
    -483,	      2336,	      4583,	     -1522,	      2338,	    -19342,	     24986,	   -362502,	    140055,	   -118693,	   -134546,	       982,
    5751,	      4414,	     14704,	    -38055,	    -28081,	    -50840,	    208442,	    140055,	 -20820834,	   -328791,	   3081671,	    -99923,
    22898,	      4601,	    174734,	   -308764,	   -507955,	   -143800,	   -230010,	   -118693,	   -328791,	  -7236926,	   -225976,	    -47887,
    -4369,	     17795,	    105587,	     10254,	     -5526,	     27527,	    -48336,	   -134546,	   3081671,	   -225976,	  -2500626,	   -124929,
    2503,	      5358,	      3797,	     11526,	     -1671,	      4324,	     -9651,	       982,	    -99923,	    -47887,	   -124929,	   -277469,
    -14533,	      3263,	     -8141,	     13301,	      5586,	      1808,	     -5289,	       472,	      7371,	    -21379,	     -2460,	       596,
    3263,	    -46002,	    -56596,	      9198,	      -765,	     13994,	      5247,	      2629,	    -14758,	    -21574,	      5644,	      3817,
    -8141,	    -56596,	   -895669,	    406276,	   -247505,	     72418,	   -246462,	     32532,	   -190899,	    -74267,	     59747,	     10271,
    13301,	      9198,	    406276,	   -551172,	    137309,	     34772,	     -5367,	     41269,	     67372,	    262339,	     42457,	     60892,
    5586,	      -765,	   -247505,	    137309,	   -964866,	    393695,	     36960,	      5148,	    114354,	     66434,	    -19640,	     18501,
    1808,	     13994,	     72418,	     34772,	    393695,	   -906317,	    366933,	     14058,	     76374,	    284422,	     16253,	     32973,
    -5289,	      5247,	   -246462,	     -5367,	     36960,	    366933,	   -711303,	     23465,	     84856,	    157990,	      2319,	     21580,
    472,	      2629,	     32532,	     41269,	      5148,	     14058,	     23465,	   -349612,	    -74011,	    -89655,	    -17686,	      7616,
    7371,	    -14758,	   -190899,	     67372,	    114354,	     76374,	     84856,	    -74011,	 -17027780,	   -264311,	    396822,	   -266476,
    -21379,	    -21574,	    -74267,	    262339,	     66434,	    284422,	    157990,	    -89655,	   -264311,	   -871539,	      3553,	      2308,
    -2460,	      5644,	     59747,	     42457,	    -19640,	     16253,	      2319,	    -17686,	    396822,	      3553,	   -334956,	    -46272,
    596,	      3817,	     10271,	     60892,	     18501,	     32973,	     21580,	      7616,	   -266476,	      2308,	    -46272,	   -357254,
    -21040,	     -1263,	     -6696,	      8169,	     -1272,	     -4427,	      4142,	     -8459,	    -63196,	    -17218,	       710,	      2270,
    -1263,	    -83196,	    -34319,	    -27267,	      2213,	      -240,	      -783,	     22287,	    136898,	      9589,	    -27942,	     -6781,
    -6696,	    -34319,	   -329281,	    107754,	       677,	    -33332,	    -46218,	     43055,	   -204958,	    -43031,	    204918,	     20438,
    8169,	    -27267,	    107754,	   -371373,	    103141,	     10674,	     46337,	     -3299,	    -65216,	    -42038,	     -5280,	     13005,
    -1272,	      2213,	       677,	    103141,	   -420124,	    194457,	      1575,	     22157,	    -26994,	     36729,	     47504,	     13852,
    -4427,	      -240,	    -33332,	     10674,	    194457,	   -368592,	    152851,	     14172,	    107043,	     44274,	    -23917,	     -8922,
    4142,	      -783,	    -46218,	     46337,	      1575,	    152851,	   -280668,	     -8210,	     40158,	     24389,	     13385,	      8410,
    -8459,	     22287,	     43055,	     -3299,	     22157,	     14172,	     -8210,	   -256064,	     79772,	     -1255,	   -101174,	       759,
    -63196,	    136898,	   -204958,	    -65216,	    -26994,	    107043,	     40158,	     79772,	 -13100212,	    263557,	   2000831,	   -242675,
    -17218,	      9589,	    -43031,	    -42038,	     36729,	     44274,	     24389,	     -1255,	    263557,	  -1223057,	   -216580,	    -23199,
    710,	    -27942,	    204918,	     -5280,	     47504,	    -23917,	     13385,	   -101174,	   2000831,	   -216580,	  -1303910,	    -90175,
    2270,	     -6781,	     20438,	     13005,	     13852,	     -8922,	      8410,	       759,	   -242675,	    -23199,	    -90175,	   -372746,
    -24335,	      -321,	     -1426,	      1524,	      1959,	     -4164,	      7012,	     -3148,	     -7859,	      9391,	      3193,	      2194,
    -321,	    -90890,	     -9068,	    -27277,	      5303,	     10922,	      2298,	     22512,	     17201,	      4798,	     13388,	     -2773,
    -1426,	     -9068,	   -180137,	     85478,	     42242,	     14714,	    -12908,	     34197,	     67246,	     40663,	     36965,	     -9792,
    1524,	    -27277,	     85478,	   -392290,	    221884,	     12492,	     33161,	    -14359,	      7950,	   -103145,	    -29210,	     -5361,
    1959,	      5303,	     42242,	    221884,	   -600963,	    259592,	     30301,	      7895,	    -32577,	   -115360,	     20766,	     -7273,
    -4164,	     10922,	     14714,	     12492,	    259592,	   -611459,	    304095,	      6323,	    -42968,	    -37072,	    -21092,	    -15235,
    7012,	      2298,	    -12908,	     33161,	     30301,	    304095,	   -467758,	     26953,	    -35709,	     29107,	     35819,	     -8754,
    -3148,	     22512,	     34197,	    -14359,	      7895,	      6323,	     26953,	   -271919,	      2988,	       852,	   -128460,	    -11407,
    -7859,	     17201,	     67246,	      7950,	    -32577,	    -42968,	    -35709,	      2988,	  -1773460,	   -215853,	    756954,	    -99883,
    9391,	      4798,	     40663,	   -103145,	   -115360,	    -37072,	     29107,	       852,	   -215853,	  -2382074,	   -108833,	      1061,
    3193,	     13388,	     36965,	    -29210,	     20766,	    -21092,	     35819,	   -128460,	    756954,	   -108833,	  -1923617,	   -116204,
    2194,	     -2773,	     -9792,	     -5361,	     -7273,	    -15235,	     -8754,	    -11407,	    -99883,	      1061,	   -116204,	   -103840
};
const Word32 lvm_noise_fx[N_MIXTURES] =
{
    /*Q10*/
    29413,	     42169,	     40240,	     39433,	     37918,	     36348
};
/* Inv possible delta used in gaus_enc (1.0/(1.0+delta*delta)) and delta = [1,7] */
const Word16 inv_delta_tab[7] =  /*Q15*/
{
    32640,
    32264,
    31655,
    30840,
    29855,
    28728,
    27504
};

const Word16 lsf_unified_fit_model_nb[4][16] =
{
    {12506 , -17641 , -6444 , -6646 , -3523 , -2132 , -511 , -92 , 699 , 1062 , 2578 , 3564 , 3200 , -285 , 2928 , -250},
    {20383 , 18855 , 8494 , 8062 , 8105 , 6211 , 5068 , 4408 , 3741 , 3458 , 2732 , 3174 , 2412 , 17421 , -21717 , 0},
    {-717 , -617 , -144 , -117 , -229 , -144 , -141 , -98 , -92 , -69 , -51 , -87 , -37 , -3019 , 19864 , 8034},
    {-2424 , 8999 , 5723 , 5629 , 4239 , 3423 , 2507 , 2019 , 1245 , 736 , -907 , -2237 , -2558 , -1979 , -652 , 1657}
};

const Word16 lsf_unified_fit_model_wb[4][16] =
{
    {8323 , -567 , 3402 , 1389 , 1437 , 1820 , 1407 , 1299 , 1292 , 1206 , 1031 , 928 , 898 , 832 , 840 , 681},
    {24635 , 19605 , 9294 , 7407 , 6419 , 5459 , 4966 , 4189 , 3394 , 2964 , 2425 , 2110 , 2140 , 1972 , 1540 , 2252},
    {-867 , -666 , -168 , -114 , -90 , -122 , -129 , -101 , -65 , -56 , -39 , -35 , -40 , -42 , -35 , -56},
    {-2313 , 3035 , 1677 , 2854 , 2334 , 1232 , 1347 , 1034 , 863 , 707 , 886 , 891 , 432 , 357 , 206 , -310}
};

const Word16 lsf_unified_fit_model_wbhb[4][16] =
{
    {5312 , 1967 , 2914 , 1438 , 2595 , 1848 , 1980 , 2021 , 1535 , 1489 , 1651 , 1502 , 1447 , 1311 , 1353 , 1202},
    {28135 , 16053 , 10129 , 7366 , 5898 , 5341 , 3290 , 2780 , 3146 , 2423 , 1613 , 1370 , 1294 , 1635 , 1105 , 1431},
    {-615 , -308 , -147 , -119 , -104 , -105 , -30 , -28 , -50 , -39 , -15 , -14 , -14 , -21 , -19 , -29},
    {1534 , 3569 , 3138 , 4023 , 2105 , 2023 , 2046 , 1264 , 1340 , 1067 , 780 , 547 , 188 , -540 , -722 , -479}
};

const Word32 Freq_Weight_Com_fx[160] =   /*Q31 */
{
    1073741824,	      1351646720,	      1610612736,	      1832992000,	      2003629568,	      2110896768,	      2147483647,	      2147483647,
    2147483647,	      2147483647,	      2147483647,	      2147483647,	      2147483647,	      2147483647,	      2147483647,	      2147483647,
    2147483647,	      2147483647,	      2147483647,	      2147483647,	      2147483647,	      2088915968,	      2033457920,	      1980868480,
    1930930688,	      1883448832,	      1838246016,	      1795162112,	      1754051584,	      1714781696,	      1677231744,	      1641291136,
    1606858368,	      1573840768,	      1542152704,	      1511715456,	      1482456448,	      1454308608,	      1427209600,	      1401102080,
    1375932672,	      1351651456,	      1328212480,	      1305572480,	      1283691392,	      1262531584,	      1242058112,	      1222238080,
    1203040640,	      1184436864,	      1166399744,	      1148903808,	      1131924864,	      1115440512,	      1099429376,	      1083871488,
    1068747648,	      1054040128,	      1039731904,	      1025806912,	      1012249984,	       999046720,	       986183488,	       973647232,
    961425728,	       949507264,	       937880640,	       926535296,	       915461184,	       904648640,	       894088512,	       883772096,
    873691072,	       863837376,	       854203520,	       844782144,	       835566336,	       826549440,	       817725120,	       809087168,
    800629824,	       792347392,	       784234624,	       776286336,	       768497472,	       760863424,	       753379520,	       746041408,
    738844864,	       731785856,	       724860416,	       718064832,	       711395520,	       704848896,	       698421760,	       692110720,
    685912704,	       679824704,	       673843840,	       667967296,	       662192384,	       656516416,	       650936960,	       645451520,
    640057792,	       634753472,	       629536320,	       624404224,	       619355136,	       614387008,	       609497984,	       604686208,
    599949760,	       595286912,	       590696000,	       586175360,	       581723392,	       577338560,	       573019328,	       568764224,
    564571840,	       560440832,	       556369856,	       552357568,	       548402752,	       544504128,	       540660608,	       536870912,
    533133984,	       529448736,	       525814080,	       522228992,	       518692448,	       515203488,	       511761152,	       508364480,
    505012640,	       501704704,	       498439808,	       495217120,	       492035872,	       488895200,	       485794400,	       482732672,
    479709280,	       476723552,	       473774752,	       470862208,	       467985248,	       465143232,	       462335520,	       459561504,
    456820576,	       454112160,	       451435648,	       448790528,	       446176224,	       443592192,	       441037920,	       438512896
};


const Word32 Freq_Weight_UV_fx[160] =   /*Q31 */
{
    1073741824,	      1351646720,	      1610612736,	      1832992000,	      2003629568,	      2110896768,	      2147483647,	      2129881344,
    2112565248,	      2095528448,	      2078764160,	      2062265984,	      2046027776,	      2030043136,	      2014306304,	      1998811648,
    1983553536,	      1968526720,	      1953725696,	      1939145728,	      1924781696,	      1910628864,	      1896682624,	      1882938624,
    1869392256,	      1856039424,	      1842876032,	      1829897984,	      1817101568,	      1804482816,	      1792038016,	      1779763840,
    1767656576,	      1755713024,	      1743929728,	      1732303488,	      1720831232,	      1709510016,	      1698336768,	      1687308544,
    1676422656,	      1665676416,	      1655067008,	      1644591872,	      1634248576,	      1624034560,	      1613947392,	      1603984640,
    1594144256,	      1584423936,	      1574821376,	      1565334528,	      1555961216,	      1546699520,	      1537547520,	      1528503040,
    1519564416,	      1510729728,	      1501997184,	      1493365120,	      1484831488,	      1476395008,	      1468053760,	      1459806336,
    1451650944,	      1443586176,	      1435610624,	      1427722624,	      1419920896,	      1412203904,	      1404570368,	      1397018880,
    1389548288,	      1382157056,	      1374844032,	      1367608064,	      1360447744,	      1353362048,	      1346349824,	      1339409920,
    1332541184,	      1325742464,	      1319012736,	      1312351104,	      1305756416,	      1299227648,	      1292763776,	      1286363904,
    1280027136,	      1273752576,	      1267539072,	      1261385984,	      1255292416,	      1249257344,	      1243280000,	      1237359616,
    1231495424,	      1225686400,	      1219932032,	      1214231424,	      1208583808,	      1202988544,	      1197444736,	      1191951872,
    1186509184,	      1181116032,	      1175771648,	      1170475264,	      1165226496,	      1160024704,	      1154868992,	      1149758976,
    1144693888,	      1139673344,	      1134696576,	      1129763200,	      1124872448,	      1120023808,	      1115216768,	      1110450944,
    1105725568,	      1101040384,	      1096394624,	      1091787904,	      1087219712,	      1082689664,	      1078197248,	      1073741824,
    1069323136,	      1064940672,	      1060593984,	      1056282624,	      1052006144,	      1047764224,	      1043556288,	      1039382080,
    1035241152,	      1031132992,	      1027057408,	      1023013888,	      1019002048,	      1015021568,	      1011072064,	      1007153152,
    1003264576,	       999405824,	       995576704,	       991776768,	       988005760,	       984263360,	       980549120,	       976862848,
    973204224,	       969572864,	       965968512,	       962390848,	       958839552,	       955314432,	       951815104,	       948341312,
};
const Word16 hann_window_320_fx[BWD_TOTAL_WIDTH/2] =
{
    /* Q15 */
    0,      3,     12,     28,     50,     79,    114,    155,
    202,    256,    316,    383,    455,    534,    618,    709,
    806,    909,   1018,   1133,   1254,   1381,   1514,   1652,
    1796,   1946,   2101,   2262,   2429,   2600,   2778,   2960,
    3148,   3340,   3538,   3741,   3949,   4161,   4378,   4600,
    4827,   5058,   5293,   5533,   5777,   6025,   6277,   6533,
    6792,   7056,   7323,   7594,   7868,   8145,   8425,   8709,
    8996,   9285,   9577,   9872,  10170,  10469,  10771,  11076,
    11382,  11690,  12000,  12312,  12625,  12940,  13256,  13574,
    13892,  14212,  14532,  14853,  15174,  15496,  15819,  16141,
    16464,  16787,  17109,  17432,  17753,  18075,  18395,  18715,
    19034,  19352,  19669,  19984,  20298,  20611,  20922,  21231,
    21538,  21844,  22147,  22448,  22746,  23043,  23336,  23627,
    23915,  24200,  24482,  24761,  25037,  25309,  25578,  25843,
    26105,  26363,  26617,  26867,  27113,  27355,  27592,  27825,
    28054,  28278,  28498,  28713,  28923,  29128,  29328,  29524,
    29714,  29899,  30079,  30253,  30422,  30586,  30744,  30897,
    31044,  31185,  31320,  31450,  31574,  31692,  31804,  31910,
    32010,  32104,  32192,  32273,  32349,  32418,  32482,  32538,
    32589,  32633,  32671,  32703,  32729,  32748,  32760,  32767
};
const Word16 W_HIST_FX[DTX_HIST_SIZE] =   {13107, 10486, 8389, 6711, 5369, 4295, 3436,  687}; /* Q16 */
const Word16 W_HIST_S_FX[DTX_HIST_SIZE] = {20480, 11378, 8393, 6938, 6092, 5551, 5183, 5115}; /* Q12 */

/*----------------------------------------------------------------------------------*
 * Starting points for pulse position search in Algebraic innovation codebook
 * Used in lib_enc\cod4t64.c
 *----------------------------------------------------------------------------------*/



const Word16 huffnorm_e_fx[32] =
{
    1062, 550, 314, 274, 273, 272, 156,  79,  69,  38,
    18,   40,  5,   3,   0,   1,   3,    4,   11,  21,
    41,   32,  35,  67,  133, 264, 530,  315, 551, 2126, 4254, 4255
};

const Word16 huffnorm_n_fx[32] =
{
    14831, 14830, 7414, 3706, 593, 927, 462, 297, 230, 116,
    50,    36,    13,   8,    5,   1,   0,   2,   6,   7,
    15,    19,    24,   56,   59,  51,  114, 117, 75,  149, 592, 1852
};

const Word16 huffsizn_e_fx[32] =
{
    13, 12, 11, 11, 11, 11, 10, 9,  9,  8,
    7,  6,  5,  4,  3,  2,  2,  3,  4,  5,
    6,  8,  8,  9,  10, 11, 12, 11, 12, 14, 15, 15
};

const Word16 huffsizn_n_fx[32] =
{
    14, 14, 13, 12, 10, 10, 9,  9,  8,  7,
    7,  6,  5,  4,  3,  3,  3,  3,  3,  4,
    4,  5,  6,  6,  6,  7,  7,  7,  7,  8, 10, 11
};

const Word16 resize_huffnorm_fx[32] =
{
    0, 0, 0, 0, 0, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1, 0,
    2, 5, 11, 23, 47, 95, 191, 383, 767, 2047, 0, 0, 0, 0, 0, 0
};

const Word16 huffnorm_fx[32] =
{
    26, 58, 90, 122, 27, 59, 91, 123, 12, 28, 44,  60,  2,  6,  4,   6,
    0,  2,  10,  14, 14, 30, 46,  62, 30, 62, 94, 126, 31, 63, 95, 127
};

const Word16 pgain_huffnorm_fx[32] =
{
    1, 1, 2, 3, 3, 2, 2, 2, 3, 3, 4, 5, 6, 7, 8, 9,
    10, 11, 12, 13, 14, 15, 4, 5, 3, 2, 3, 3, 4, 5, 0, 1
};

const Word16 hessize_fx[8]=
{
    7, 5, 3, 2, 1, 4, 6, 7
};

const Word16 hescode_fx[8]=
{
    11, 3, 1, 1, 1, 0, 4, 10
};

/*----------------------------------------------------------------------------------*
 *   Encoder TABLE ROM
 *----------------------------------------------------------------------------------*/

/* [129] - half of the square root hanning window for spectral analysis and NS */
const Word16 sqrt_han_window[L_FFT/2+1] =
{
    0,   402,   804,  1206,  1608,  2009,  2410,  2811,  3212,
    3612,  4011,  4410,  4808,  5205,  5602,  5998,  6393,  6786,
    7179,  7571,  7962,  8351,  8739,  9126,  9512,  9896, 10278,
    10659, 11039, 11417, 11793, 12167, 12539, 12910, 13279, 13645,
    14010, 14372, 14732, 15090, 15446, 15800, 16151, 16499, 16846,
    17189, 17530, 17869, 18204, 18537, 18868, 19195, 19519, 19841,
    20159, 20475, 20787, 21096, 21403, 21705, 22005, 22301, 22594,
    22884, 23170, 23452, 23731, 24007, 24279, 24547, 24811, 25072,
    25329, 25582, 25832, 26077, 26319, 26556, 26790, 27019, 27245,
    27466, 27683, 27896, 28105, 28310, 28510, 28706, 28898, 29085,
    29268, 29447, 29621, 29791, 29956, 30117, 30273, 30424, 30571,
    30714, 30852, 30985, 31113, 31237, 31356, 31470, 31580, 31685,
    31785, 31880, 31971, 32057, 32137, 32213, 32285, 32351, 32412,
    32469, 32521, 32567, 32609, 32646, 32678, 32705, 32728, 32745,
    32757, 32765, 32767
};

/*------------------------------------------------------------------------------*
 * Critical bands in Q0
 *------------------------------------------------------------------------------*/
const Word16 crit_bands[] =
{
    100,  200,  300,  400,  510,  630,  770,  920, 1080, 1270,
    1480, 1720, 2000, 2320, 2700, 3150, 3700, 4400, 5300, 6350
};

/*----------------------------------------------------------------------------------*
 * Open-loop pitch tables,
 * Used in lib_enc\pitch_ol.c
 *----------------------------------------------------------------------------------*/


/* integer square (i*i) */
const Word16 int_sqr[17] =
{
    0, 1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256
};


/*ari_hm_enc.c*/
/* Q13 format */
const Word16 kLowPeriodicityThr[2] = { FL2WORD16_SCALE(0.5f,2), FL2WORD16_SCALE(0.2f,2) };

/* pow(3 * i + 1, 0.3) / pow(256 - 1, 0.3) */
const Word16 Weight[86] =
{
    0x1848, 0x24CD, 0x2B87, 0x3072, 0x3469, 0x37C8, 0x3ABB, 0x3D5F, 0x3FC6, 0x41FA, 0x4406, 0x45EF, 0x47BB, 0x496E, 0x4B0A,
    0x4C93, 0x4E0A, 0x4F71, 0x50CA, 0x5216, 0x5357, 0x548C, 0x55B8, 0x56DA, 0x57F4, 0x5905, 0x5A10, 0x5B13, 0x5C10, 0x5D06, 0x5DF7,
    0x5EE2, 0x5FC8, 0x60A9, 0x6185, 0x625D, 0x6331, 0x6401, 0x64CD, 0x6595, 0x6659, 0x671B, 0x67D9, 0x6893, 0x694B, 0x6A00, 0x6AB2,
    0x6B62, 0x6C0F, 0x6CB9, 0x6D61, 0x6E07, 0x6EAB, 0x6F4C, 0x6FEB, 0x7088, 0x7124, 0x71BD, 0x7254, 0x72EA, 0x737E, 0x7410, 0x74A1,
    0x752F, 0x75BD, 0x7649, 0x76D3, 0x775C, 0x77E3, 0x7869, 0x78EE, 0x7971, 0x79F3, 0x7A74, 0x7AF4, 0x7B72, 0x7BF0, 0x7C6C, 0x7CE7,
    0x7D61, 0x7DDA, 0x7E51, 0x7EC8, 0x7F3E, 0x7FB3, 0x7FFF
};

const Word16 lsf_numlevels[TCXLPC_NUMSTAGES] = { 32, 16, 16 };
const Word16 lsf_ind_numlevels[TCXLPC_IND_NUMSTAGES] = { 4 };

/*----------------------------------------------------------------------------------*
 * Starting line for the noise measurement in TCX.
 *----------------------------------------------------------------------------------*/
const Word16 startLineWB[11]  = { 8, 23, 36, 45, 66, 128 /* 13.2kbps */, 200, 320, 320, 320 /* 48kbps */, 320 };
const Word16 startLineSWB[9] = { 8, 44,  96 /* 13.2kbps */, 160, 320, 320, 256 /* 48kbps */, 341, 640 };

/*----------------------------------------------------------------------------------*
 * CLDFB-based VAD
 *----------------------------------------------------------------------------------*/
/* SNR_calc.c */
const Word16 Nregion_index_NB[9]   = {0,1,2,3,4,5,6,7, 9};
const Word16 Nregion_index_WB[13]  = {0,1,2,3,4,5,6,8,10,12,16};
const Word16 Nregion_index_SWB[16] = {0,1,2,3,4,5,6,8,10,12,16,24,36};
const Word16 Nregion_index_FB[16]  = {0,1,2,3,4,5,6,8,10,12,16,24,36};
const Word16 Nregion_preoff[12] = {0,0,0,0,0,0,1,1,1,2,3,4};
const Word16 SNR_SUB_BAND_NUM[4] = {8,10,12,12};
const Word16 BAND_MUL[4] = {CONST_16_Q15(1/8.0),CONST_16_Q15(1/10.0),CONST_16_Q15(1/12.0),CONST_16_Q15(1/12.0)};
const Word16 *REGION_INDEX[4] = {Nregion_index_NB, Nregion_index_WB,Nregion_index_SWB,Nregion_index_FB};
const Word32 MAX_LF_SNR_TAB[5] = {CONST_32_Q25(0.8),CONST_32_Q25(0.8),CONST_32_Q25(1.6),CONST_32_Q25(0.8),CONST_32_Q25(0.8)};
const Word32 LS_MIN_SILENCE_SNR[4] = {CONST_32_Q25(7.5f), CONST_32_Q25(7.5f), CONST_32_Q25(6.8f),CONST_32_Q25(6.8f)};
const Word32 LT_MIN_SILENCE_SNR[4] = {CONST_32_Q25(4.5f), CONST_32_Q25(4.5f), CONST_32_Q25(4.5f),CONST_32_Q25(4.5f)};
const Word32 COMVAD_INIT_SNR_DELTA[5] = {CONST_32_Q25(1.0f), CONST_32_Q25(0.6f), CONST_32_Q25(0.86f), CONST_32_Q25(1.16f), CONST_32_Q25(1.0f)};

/* spec_center.c */
const Word16 i_t_1[10]= {2048,4096,6144,8192,10240,12288,14336,16384,18432,20480};
const Word16 i_t_2[23]= {1024,2048,3072,4096,5120,6144,7168,8192,9216,10240,11264,12288,13312,14336,15360,16384,17408,18432,19456,20480,21504,22528,23552};

/* subband_fft.c */
const complex_16 wnk_table_16[16] =
{
    {32767, 0}, {30274, 12540}, {23170, 23170}, {12540, 30274},
    {32767, 0}, {23170, 23170}, {0, 32767}, {-23170, 23170},
    {32767, 0}, {12540, 30274}, {-23170, 23170}, {-30274, -12540},
    {32767, 0}, {32767, 0}, {32767, 0}, {0, -32768},
};

/*  x(n)*W_2N^n */
const complex_16 M_in_fix16[16] =
{
    {32767, 0}, {32138, 6393}, {30274, 12540}, {27246, 18205},
    {23170, 23170}, {18205, 27246}, {12540, 30274}, {6393, 32138},
    {0, 32767}, {-6393, 32138}, {-12540, 30274}, {-18205, 27246},
    {-23170, 23170},{ -27246, 18205}, {-30274, 12540}, {-32138, 6393},
};
/*W_2N^(k+1/2)*/

const Word16 M_Wr_fix16[16] =
{
    CONST_16_Q15(9.9518473e-001f),CONST_16_Q15(  9.5694034e-001f),CONST_16_Q15(  8.8192126e-001f),CONST_16_Q15(  7.7301045e-001f),CONST_16_Q15(  6.3439328e-001f),CONST_16_Q15(  4.7139674e-001f),CONST_16_Q15(  2.9028468e-001f),CONST_16_Q15(  9.8017140e-002f),
    CONST_16_Q15(-9.8017140e-002f),CONST_16_Q15( -2.9028468e-001f),CONST_16_Q15( -4.7139674e-001f),CONST_16_Q15( -6.3439328e-001f),CONST_16_Q15( -7.7301045e-001f),CONST_16_Q15( -8.8192126e-001f),CONST_16_Q15( -9.5694034e-001f),CONST_16_Q15( -9.9518473e-001f)
};

const Word16 M_Wi_fix16[16] =
{
    CONST_16_Q15(9.8017140e-002f),CONST_16_Q15(  2.9028468e-001f),CONST_16_Q15( 4.7139674e-001f),CONST_16_Q15( 6.3439328e-001f),CONST_16_Q15( 7.7301045e-001f),CONST_16_Q15( 8.8192126e-001f),CONST_16_Q15( 9.5694034e-001f),CONST_16_Q15( 9.9518473e-001f),
    CONST_16_Q15(9.9518473e-001f),CONST_16_Q15( 9.5694034e-001f),CONST_16_Q15( 8.8192126e-001f),CONST_16_Q15( 7.7301045e-001f),CONST_16_Q15( 6.3439328e-001f),CONST_16_Q15( 4.7139674e-001f),CONST_16_Q15( 2.9028468e-001f),CONST_16_Q15( 9.8017140e-002f)
};

/* vad_proc.c */
const Word16 BAND_NUM_TAB[5] = {10,10,20,40,60};  /* {OFFSET, NB, WB, SWB, FB} */
const Word16 BAND_SCALE_AJ[5] = {3,3,5,6,6};  /* {OFFSET, NB, WB, SWB, FB} */

/* enc_acelp.c, enc_acelpx.c */
UWord8 E_ROM_tipos[40] =
{
    0, 1, 2, 3, /* starting point &ipos[0], 1st iter */
    1, 2, 3, 0, /* starting point &ipos[4], 2nd iter */
    2, 3, 0, 1, /* starting point &ipos[8], 3rd iter */
    3, 0, 1, 2, /* starting point &ipos[12], 4th iter */
    0, 1, 2, 3,
    1, 2, 3, 0,
    2, 3, 0, 1,
    3, 0, 1, 2,
    0, 1, 2, 3, /* end point for 24 pulses &ipos[35], 4th iter */
    1, 2, 3, 0 /* end point for 36 pulses &ipos[39], 2nd iter */
};

/* bw_detect_fx.c */
const Word16 bwd_start_bin_fx[4] = {1, 3, 6, 11};
const Word16 bwd_end_bin_fx[4] = {1, 4, 9, 12};





